import { defineStore } from 'pinia'
import { sourceHeader } from '@/utils/plugins'

interface musicState {
    musicDataList: musicDataList[]
    musicItemDataList: string[]
}

interface musicDataList {
    id: string | null
    title: string | null
    author: string | null
    img: string | null
    song: string | null
}


const musicStore = defineStore('musicDataStore', {
    state: ():musicState  => {
        return {
            // 音乐列表数据
            musicDataList: [
                {
                    id: '1',
                    title: 'Cornfield Chase',
                    author: 'Hans Zimmer',
                    img: sourceHeader() + '/image/music/Cornfield Chase.jpg',
                    song: sourceHeader() + '/image/music/Cornfield Chase.mp3',
                },
                {
                    id: '2',
                    title: 'Call of Silence',
                    author: '澤野弘之',
                    img: sourceHeader() + '/image/music/Call of Silence.jpg',
                    song: sourceHeader() + '/image/music/Call of Silence.mp3',
                },
                {
                    id: '3',
                    title: '苏州河',
                    author: '薛凯琪',
                    img: sourceHeader() + '/image/music/苏州河.jpg',
                    song: sourceHeader() + '/image/music/苏州河.mp3',
                },
                {
                    id: '4',
                    title: '紧急联络人',
                    author: 'Gareth.T',
                    img: sourceHeader() + '/image/music/紧急联络人.jpg',
                    song: sourceHeader() + '/image/music/紧急联络人.mp3',
                },
                {
                    id: '5',
                    title: '国际孤独等级',
                    author: 'Gareth.T',
                    img: sourceHeader() + '/image/music/国际孤独等级.jpg',
                    song: sourceHeader() + '/image/music/国际孤独等级.mp3',
                },
                {
                    id: '6',
                    title: 'Tek It',
                    author: 'Cafuné',
                    img: sourceHeader() + '/image/music/Tek It.jpg',
                    song: sourceHeader() + '/image/music/Tek It.mp3',
                },
                {
                    id: '7',
                    title: '一路向北',
                    author: '周杰伦',
                    img: sourceHeader() + '/image/music/周杰伦1.jpg',
                    song: sourceHeader() + '/image/music/一路向北.mp3',
                },
                {
                    id: '8',
                    title: '一点点',
                    author: '周杰伦-床边故事',
                    img: sourceHeader() + '/image/music/周杰伦2.jpg',
                    song: sourceHeader() + '/image/music/一点点.mp3',
                },
                {
                    id: '9',
                    title: '红尘客栈',
                    author: '周杰伦',
                    img: sourceHeader() + '/image/music/周杰伦3.jpg',
                    song: sourceHeader() + '/image/music/红尘客栈.mp3',
                },
                {
                    id: '10',
                    title: '兰亭序',
                    author: '周杰伦-魔杰座',
                    img: sourceHeader() + '/image/music/周杰伦4.jpg',
                    song: sourceHeader() + '/image/music/兰亭序.mp3',
                },
                {
                    id: '11',
                    title: '晴天',
                    author: '周杰伦',
                    img: sourceHeader() + '/image/music/周杰伦5.jpg',
                    song: sourceHeader() + '/image/music/晴天.mp3',
                },
                {
                    id: '12',
                    title: '七里香',
                    author: '周杰伦',
                    img: sourceHeader() + '/image/music/周杰伦6.jpg',
                    song: sourceHeader() + '/image/music/七里香.mp3',
                },
                {
                    id: '13',
                    title: '半岛铁盒',
                    author: '周杰伦',
                    img: sourceHeader() + '/image/music/周杰伦7.jpg',
                    song: sourceHeader() + '/image/music/半岛铁盒.mp3',
                },
                {
                    id: '14',
                    title: '发如雪',
                    author: '周杰伦',
                    img: sourceHeader() + '/image/music/周杰伦8.jpg',
                    song: sourceHeader() + '/image/music/发如雪.mp3',
                },
                {
                    id: '15',
                    title: '枫',
                    author: '周杰伦',
                    img: sourceHeader() + '/image/music/周杰伦8.jpg',
                    song: sourceHeader() + '/image/music/枫.mp3',
                },
                {
                    id: '16',
                    title: '可爱女人',
                    author: '周杰伦',
                    img: sourceHeader() + '/image/music/周杰伦9.jpg',
                    song: sourceHeader() + '/image/music/可爱女人.mp3',
                },
                {
                    id: '17',
                    title: '搁浅',
                    author: '周杰伦',
                    img: sourceHeader() + '/image/music/周杰伦6.jpg',
                    song: sourceHeader() + '/image/music/搁浅.mp3',
                },
                {
                    id: '18',
                    title: '夜曲',
                    author: '周杰伦',
                    img: sourceHeader() + '/image/music/周杰伦8.jpg',
                    song: sourceHeader() + '/image/music/夜曲.mp3',
                },
                {
                    id: '19',
                    title: '明明就',
                    author: '周杰伦',
                    img: sourceHeader() + '/image/music/周杰伦3.jpg',
                    song: sourceHeader() + '/image/music/明明就.mp3',
                },
                {
                    id: '20',
                    title: '青花瓷',
                    author: '周杰伦',
                    img: sourceHeader() + '/image/music/周杰伦10.jpg',
                    song: sourceHeader() + '/image/music/青花瓷.mp3',
                },
                {
                    id: '21',
                    title: '霍元甲',
                    author: '周杰伦',
                    img: sourceHeader() + '/image/music/周杰伦11.jpg',
                    song: sourceHeader() + '/image/music/霍元甲.mp3',
                },
                {
                    id: '22',
                    title: '稻香',
                    author: '周杰伦',
                    img: sourceHeader() + '/image/music/周杰伦4.jpg',
                    song: sourceHeader() + '/image/music/稻香.mp3',
                },
                {
                    id: '23',
                    title: '说好的幸福呢',
                    author: '周杰伦',
                    img: sourceHeader() + '/image/music/周杰伦4.jpg',
                    song: sourceHeader() + '/image/music/说好的幸福呢.mp3',
                },
                {
                    id: '24',
                    title: '甜甜的',
                    author: '周杰伦',
                    img: sourceHeader() + '/image/music/周杰伦10.jpg',
                    song: sourceHeader() + '/image/music/甜甜的.mp3',
                },
                {
                    id: '25',
                    title: '听妈妈的话',
                    author: '周杰伦-依然范特西',
                    img: sourceHeader() + '/image/music/周杰伦12.jpg',
                    song: sourceHeader() + '/image/music/听妈妈的话.mp3',
                },
                {
                    id: '26',
                    title: '爱错',
                    author: '王力宏',
                    img: sourceHeader() + '/image/music/王力宏.jpg',
                    song: sourceHeader() + '/image/music/爱错.mp3',
                },
                {
                    id: '27',
                    title: '普通朋友',
                    author: '陶喆',
                    img: sourceHeader() + '/image/music/陶喆.jpg',
                    song: sourceHeader() + '/image/music/普通朋友.mp3',
                },
                {
                    id: '28',
                    title: '特别的人',
                    author: '方大同',
                    img: sourceHeader() + '/image/music/方大同.jpg',
                    song: sourceHeader() + '/image/music/特别的人.mp3',
                },
                {
                    id: '29',
                    title: '下完这场雨',
                    author: '后弦',
                    img: sourceHeader() + '/image/music/后弦.jpg',
                    song: sourceHeader() + '/image/music/下完这场雨.mp3',
                },
                {
                    id: '30',
                    title: '至少做一件离谱的事',
                    author: 'Kiri T',
                    img: sourceHeader() + '/image/music/至少做一件离谱的事.jpg',
                    song: sourceHeader() + '/image/music/至少做一件离谱的事.mp3',
                },
                {
                    id: '31',
                    title: '有些话要用英文说',
                    author: 'Kiri T',
                    img: sourceHeader() + '/image/music/有些话要用英文说.jpg',
                    song: sourceHeader() + '/image/music/有些话要用英文说.mp3',
                },
                {
                    id: '32',
                    title: '起风的季节',
                    author: '陈默之',
                    img: sourceHeader() + '/image/music/起风的季节.jpg',
                    song: sourceHeader() + '/image/music/起风的季节.mp3',
                },
                {
                    id: '33',
                    title: '夜に駆ける',
                    author: 'YOASOBI',
                    img: sourceHeader() + '/image/music/夜に駆ける.jpg',
                    song: sourceHeader() + '/image/music/夜に駆ける.mp3',
                },
                {
                    id: '34',
                    title: 'Into The Night',
                    author: 'YOASOBI',
                    img: sourceHeader() + '/image/music/Into The Night.jpg',
                    song: sourceHeader() + '/image/music/Into The Night.mp3',
                },
                {
                    id: '35',
                    title: 'Havent',
                    author: 'YOASOBI',
                    img: sourceHeader() + '/image/music/Havent.jpg',
                    song: sourceHeader() + '/image/music/Havent.mp3',
                },
                {
                    id: '36',
                    title: '夜行2.0',
                    author: '队长',
                    img: sourceHeader() + '/image/music/夜行2.0.jpg',
                    song: sourceHeader() + '/image/music/夜行2.0.mp3',
                },
                {
                    id: '37',
                    title: '哪里都是你',
                    author: '队长',
                    img: sourceHeader() + '/image/music/哪里都是你.jpg',
                    song: sourceHeader() + '/image/music/哪里都是你.mp3',
                },
                {
                    id: '38',
                    title: '予你',
                    author: '队长',
                    img: sourceHeader() + '/image/music/予你.jpg',
                    song: sourceHeader() + '/image/music/予你.mp3',
                },
                {
                    id: '39',
                    title: '富士山下',
                    author: '陈奕迅',
                    img: sourceHeader() + '/image/music/富士山下.jpg',
                    song: sourceHeader() + '/image/music/富士山下.mp3',
                },
                {
                    id: '40',
                    title: '岁月如歌',
                    author: '陈奕迅',
                    img: sourceHeader() + '/image/music/岁月如歌.jpg',
                    song: sourceHeader() + '/image/music/岁月如歌.mp3',
                },
                {
                    id: '41',
                    title: '镜中花',
                    author: '任子墨,HIGH5-马思涵SAI',
                    img: sourceHeader() + '/image/music/镜中花.jpg',
                    song: sourceHeader() + '/image/music/镜中花.mp3',
                },
            ],
            musicItemDataList: [], // 音乐列表中当前选中的项
        }
    },
    actions: {
        handlerSetmusicItemDataList(val: any) { // 立即播放某项
            this.musicItemDataList = []
            this.musicItemDataList.push(val)
        },
        handlerSetmusicDataList(val: any) { // 将某项数据添加到列表中第一项
            let index = this.musicDataList.findIndex((item: any) => item.id == val.id)
            if (index > -1) {
                this.musicDataList.splice(index, 1)
                this.musicDataList.unshift(val)
            }
        }
    }
})

export default musicStore